﻿Imports System.Data.SqlClient

Public Class clsObservaciones
    Private mintIdObservacion As Integer
    Private mintidEmpleado As Integer
    Private mstrObservacion As String
    Private mstrCapturo As String
    Private mstrReportado As String
    Private mdatFecha As Date
    Public Property idObservacion() As Integer
        Get
            Return mintIdObservacion
        End Get
        Set(ByVal value As Integer)
            mintIdObservacion = value
        End Set
    End Property

    Public Property idempleado() As Integer
        Get
            Return mintidEmpleado
        End Get
        Set(ByVal value As Integer)
            mintidEmpleado = value
        End Set
    End Property

    Public Property Observacion() As String
        Get
            Return mstrObservacion
        End Get
        Set(ByVal value As String)
            mstrObservacion = value
        End Set
    End Property
    Public Property Capturo() As String
        Get
            Return mstrCapturo
        End Get
        Set(ByVal value As String)
            mstrCapturo = value
        End Set
    End Property
    Public Property Reportado() As String
        Get
            Return mstrReportado
        End Get
        Set(ByVal value As String)
            mstrReportado = value
        End Set
    End Property
    Public Property Fecha() As Date
        Get
            Return mdatFecha
        End Get
        Set(ByVal value As Date)
            mdatFecha = value
        End Set
    End Property
    Public Sub New()
        mintIdObservacion = 0
        mintidEmpleado = 0
        mdatFecha = Now()
        mstrObservacion = ""
        mstrCapturo = ""
        mstrReportado = ""
    End Sub
    Public Sub Borrar()
        Call SetSqlCitra("Delete From Observaciones Where idObservacion = " & idObservacion)

    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into observaciones (" & _
                            "IdObservacion," & _
                            "IdEmpleado," & _
                            "Observacion," & _
                            "Capturo," & _
                            "Reportado," & _
                            "Fecha)" & _
                            "VALUES (" & _
                            "@IdObservacion," & _
                            "@IdEmpleado," & _
                            "@Observacion," & _
                            "@Capturo," & _
                            "@Reportado," & _
                            "@Fecha)"

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdObservacion", mintIdObservacion)
        Command.Parameters.AddWithValue("IdEmpleado", mintidEmpleado)
        Command.Parameters.AddWithValue("Observacion", mstrObservacion)
        Command.Parameters.AddWithValue("Capturo", mstrCapturo)
        Command.Parameters.AddWithValue("Reportado", mstrReportado)
        Command.Parameters.AddWithValue("Fecha", mdatFecha)
        

        cnConn.Open()
        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el registro ", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
